
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Adapters · RxDB - Documentation</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="plugins.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://twitter.com/rxdbjs" target="_blank" class="custom-link">Follow @twitter </a>
        </li>
    
        
        <li>
            <a href="https://gitter.im/pubkey/rxdb" target="_blank" class="custom-link">Chat @gitter </a>
        </li>
    
        
        <li>
            <a href="https://github.com/pubkey/rxdb" target="_blank" class="custom-link">Star @github </a>
        </li>
    
        
        <li>
            <a href="https://www.patreon.com/rxdb/" target="_blank" class="custom-link">Donate @patreon </a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="install.html">
            
                <a href="install.html">
            
                    
                    Install
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="install.html">
            
                <a href="install.html#npm">
            
                    
                    npm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="install.html">
            
                <a href="install.html#import">
            
                    
                    import
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="rx-database.html">
            
                <a href="rx-database.html">
            
                    
                    RxDatabase
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="rx-database.html">
            
                <a href="rx-database.html#creation">
            
                    
                    Creation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="rx-database.html">
            
                <a href="rx-database.html#name">
            
                    
                    name
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="rx-database.html">
            
                <a href="rx-database.html#adapter">
            
                    
                    adapter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.3" data-path="rx-database.html">
            
                <a href="rx-database.html#password">
            
                    
                    password
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.4" data-path="rx-database.html">
            
                <a href="rx-database.html#multiinstance">
            
                    
                    multiInstance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.5" data-path="rx-database.html">
            
                <a href="rx-database.html#eventreduce">
            
                    
                    eventReduce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.6" data-path="rx-database.html">
            
                <a href="rx-database.html#ignoreduplicate">
            
                    
                    ignoreDuplicate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.7" data-path="rx-database.html">
            
                <a href="rx-database.html#pouchSettings">
            
                    
                    pouchSettings
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="rx-database.html">
            
                <a href="rx-database.html#functions">
            
                    
                    Functions
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="rx-database.html">
            
                <a href="rx-database.html#observe-with-">
            
                    
                    $
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="rx-database.html">
            
                <a href="rx-database.html#dump">
            
                    
                    dump()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.3" data-path="rx-database.html">
            
                <a href="rx-database.html#importdump">
            
                    
                    importDump()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.4" data-path="rx-database.html">
            
                <a href="rx-database.html#server">
            
                    
                    server()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.5" data-path="rx-database.html">
            
                <a href="rx-database.html#waitforleadership">
            
                    
                    waitForLeadership()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.6" data-path="rx-database.html">
            
                <a href="rx-database.html#requestidlepromise">
            
                    
                    requestIdlePromise()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.7" data-path="rx-database.html">
            
                <a href="rx-database.html#destroy">
            
                    
                    destroy()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.8" data-path="rx-database.html">
            
                <a href="rx-database.html#remove">
            
                    
                    remove()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.9" data-path="rx-database.html">
            
                <a href="rx-database.html#checkadapter">
            
                    
                    checkAdapter()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.10" data-path="rx-database.html">
            
                <a href="rx-database.html#isrxdatabase">
            
                    
                    isRxDatabase()
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="rx-schema.html">
            
                <a href="rx-schema.html">
            
                    
                    RxSchema
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="rx-schema.html">
            
                <a href="rx-schema.html#example">
            
                    
                    Example
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="rx-schema.html">
            
                <a href="rx-schema.html#create-a-collection-with-the-schema">
            
                    
                    Create a collection with the schema
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="rx-schema.html">
            
                <a href="rx-schema.html#version">
            
                    
                    version
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="rx-schema.html">
            
                <a href="rx-schema.html#keycompression">
            
                    
                    keyCompression
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="rx-schema.html">
            
                <a href="rx-schema.html#indexes">
            
                    
                    indexes
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="rx-schema.html">
            
                <a href="rx-schema.html#attachments">
            
                    
                    attachments
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="rx-schema.html">
            
                <a href="rx-schema.html#default">
            
                    
                    default
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="rx-schema.html">
            
                <a href="rx-schema.html#final">
            
                    
                    final
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="rx-schema.html">
            
                <a href="rx-schema.html#encryption">
            
                    
                    encryption
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="rx-collection.html">
            
                <a href="rx-collection.html">
            
                    
                    RxCollection
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="rx-collection.html">
            
                <a href="rx-collection.html#creating-a-collection">
            
                    
                    Creation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="rx-collection.html">
            
                <a href="rx-collection.html#name">
            
                    
                    name
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="rx-collection.html">
            
                <a href="rx-collection.html#schema">
            
                    
                    schema
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.3" data-path="rx-collection.html">
            
                <a href="rx-collection.html#pouchSettings">
            
                    
                    pouchSettings
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.4" data-path="rx-collection.html">
            
                <a href="rx-collection.html#orm-functions">
            
                    
                    ORM-functions
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.5" data-path="rx-collection.html">
            
                <a href="rx-collection.html#Migration">
            
                    
                    Migration
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="rx-collection.html">
            
                <a href="rx-collection.html#functions">
            
                    
                    Functions
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="rx-collection.html">
            
                <a href="rx-collection.html#observe-">
            
                    
                    $
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.2" data-path="rx-collection.html">
            
                <a href="rx-collection.html#insert">
            
                    
                    insert()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.3" data-path="rx-collection.html">
            
                <a href="rx-collection.html#newdocument">
            
                    
                    newDocument()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.4" data-path="rx-collection.html">
            
                <a href="rx-collection.html#upsert">
            
                    
                    upsert()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.5" data-path="rx-collection.html">
            
                <a href="rx-collection.html#atomicupsert">
            
                    
                    atomicUpsert()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.6" data-path="rx-collection.html">
            
                <a href="rx-collection.html#find">
            
                    
                    find()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.7" data-path="rx-collection.html">
            
                <a href="rx-collection.html#findone">
            
                    
                    findOne()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.8" data-path="rx-collection.html">
            
                <a href="rx-collection.html#findByIds">
            
                    
                    findByIds()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.9" data-path="rx-collection.html">
            
                <a href="rx-collection.html#dump">
            
                    
                    dump()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.10" data-path="rx-collection.html">
            
                <a href="rx-collection.html#importdump">
            
                    
                    importDump()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.11" data-path="rx-collection.html">
            
                <a href="rx-collection.html#sync">
            
                    
                    sync()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.12" data-path="rx-collection.html">
            
                <a href="rx-collection.html#remove">
            
                    
                    remove()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.13" data-path="rx-collection.html">
            
                <a href="rx-collection.html#destroy">
            
                    
                    destroy()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.14" data-path="rx-collection.html">
            
                <a href="rx-collection.html#isrxcollection">
            
                    
                    isRxCollection()
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="rx-document.html">
            
                <a href="rx-document.html">
            
                    
                    RxDocument
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="rx-document.html">
            
                <a href="rx-document.html#insert">
            
                    
                    Insert
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="rx-document.html">
            
                <a href="rx-document.html#find">
            
                    
                    Find
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="rx-document.html">
            
                <a href="rx-document.html#functions">
            
                    
                    Functions
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="rx-document.html">
            
                <a href="rx-document.html#get">
            
                    
                    get()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="rx-document.html">
            
                <a href="rx-document.html#get$">
            
                    
                    get$()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.3" data-path="rx-document.html">
            
                <a href="rx-document.html#proxy-get">
            
                    
                    proxy-get
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.4" data-path="rx-document.html">
            
                <a href="rx-document.html#update">
            
                    
                    update()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.5" data-path="rx-document.html">
            
                <a href="rx-document.html#atomicupdate">
            
                    
                    atomicUpdate()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.6" data-path="rx-document.html">
            
                <a href="rx-document.html#atomicset">
            
                    
                    atomicSet()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.7" data-path="rx-document.html">
            
                <a href="rx-document.html#observe-">
            
                    
                    $
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.8" data-path="rx-document.html">
            
                <a href="rx-document.html#remove">
            
                    
                    remove()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.9" data-path="rx-document.html">
            
                <a href="rx-document.html#deleted$">
            
                    
                    deleted$
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.10" data-path="rx-document.html">
            
                <a href="rx-document.html#tojson">
            
                    
                    toJSON()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.11" data-path="rx-document.html">
            
                <a href="rx-document.html#set">
            
                    
                    set()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.12" data-path="rx-document.html">
            
                <a href="rx-document.html#save">
            
                    
                    save()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.13" data-path="rx-document.html">
            
                <a href="rx-document.html#isrxdocument">
            
                    
                    isRxDocument()
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="rx-query.html">
            
                <a href="rx-query.html">
            
                    
                    RxQuery
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="rx-query.html">
            
                <a href="rx-query.html#find">
            
                    
                    find()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="rx-query.html">
            
                <a href="rx-query.html#findOne">
            
                    
                    findOne()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="rx-query.html">
            
                <a href="rx-query.html#exec">
            
                    
                    exec()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="rx-query.html">
            
                <a href="rx-query.html#observe-">
            
                    
                    $
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="rx-query.html">
            
                <a href="rx-query.html#update">
            
                    
                    update()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="rx-query.html">
            
                <a href="rx-query.html#remove">
            
                    
                    remove()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="rx-query.html">
            
                <a href="rx-query.html#doesDocumentDataMatch">
            
                    
                    doesDocumentDataMatch()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="rx-query.html">
            
                <a href="rx-query.html#examples">
            
                    
                    Examples
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="rx-query.html">
            
                <a href="rx-query.html#isrxquery">
            
                    
                    isRxQuery()
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="rx-attachment.html">
            
                <a href="rx-attachment.html">
            
                    
                    RxAttachment
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="middleware.html">
            
                <a href="middleware.html">
            
                    
                    Middleware-hooks
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="orm.html">
            
                <a href="orm.html">
            
                    
                    ORM/DRM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="population.html">
            
                <a href="population.html">
            
                    
                    Population
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="data-migration.html">
            
                <a href="data-migration.html">
            
                    
                    DataMigration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="leader-election.html">
            
                <a href="leader-election.html">
            
                    
                    LeaderElection
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="replication.html">
            
                <a href="replication.html">
            
                    
                    Replication CouchDB
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="replication-graphql.html">
            
                <a href="replication-graphql.html">
            
                    
                    Replication GraphQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="in-memory.html">
            
                <a href="in-memory.html">
            
                    
                    InMemory
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="rx-local-document.html">
            
                <a href="rx-local-document.html">
            
                    
                    LocalDocuments
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="custom-build.html">
            
                <a href="custom-build.html">
            
                    
                    Custom Build
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="plugins.html">
            
                <a href="plugins.html">
            
                    
                    Plugins
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.20" data-path="adapters.html">
            
                <a href="adapters.html">
            
                    
                    Adapters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" >
            
                <span>
            
                    
                    Tutorials
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.21.1" data-path="tutorials/typescript.html">
            
                <a href="tutorials/typescript.html">
            
                    
                    Use RxDB with Typescript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.2" data-path="tutorials/server.html">
            
                <a href="tutorials/server.html">
            
                    
                    Using the Server Plugin
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="questions-answers.html">
            
                <a href="questions-answers.html">
            
                    
                    Questions & Answers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="contribute.html">
            
                <a href="contribute.html">
            
                    
                    Contribute
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Adapters</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="adapters">Adapters</h1>
<p>RxDB itself is not a self-contained database. It uses adapters that define where the data is stored. Depending on which environment you work in, you can choose between different adapters. For example in the browser you want to store the data inside of IndexedDB but on NodeJs you want to store the data on the filesystem.</p>
<p>This page is an overview over the different adapters with recommendations on what to use where.</p>
<p><strong>Please always ensure that your pouchdb adapter-version is the same as <code>pouchdb-core</code> in the <a href="https://github.com/pubkey/rxdb/blob/master/package.json" target="_blank">rxdb package.json</a>. Otherwise you might have strange problems</strong></p>
<h1 id="any-environment">Any environment</h1>
<h2 id="memory">Memory</h2>
<p>In any environment, you can use the memory-adapter. It stores the data in the javascript runtime memory. This means it is not persistent and the data is lost when the process terminates.</p>
<p>Use this adapter when:</p>
<ul>
<li>You want to have a really good performance</li>
<li>You do not want persistent state, for example in your test suite</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-memory --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-memory&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;memory&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h2 id="memdown">Memdown</h2>
<p>With RxDB you can also use adapters that implement <a href="https://github.com/Level/abstract-leveldown" target="_blank">abstract-leveldown</a> like the memdown-adapter.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install memdown --save</span>
<span class="hljs-comment">// npm install pouchdb-adapter-leveldb --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-leveldb&apos;</span>)); <span class="hljs-comment">// leveldown adapters need the leveldb plugin to work</span>

<span class="hljs-keyword">const</span> memdown = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;memdown&apos;</span>);

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: memdown <span class="hljs-comment">// the full leveldown-module</span>
});
</code></pre>
<h1 id="browser">Browser</h1>
<h2 id="indexeddb">IndexedDB</h2>
<p>The IndexedDB adapter stores the data inside of <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API" target="_blank">IndexedDB</a> use this in browsers environments as default.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-idb --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-idb&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;idb&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h2 id="websql">Websql</h2>
<p>This adapter stores the data inside of websql. It has a different performance behavior. <a href="https://softwareengineering.stackexchange.com/questions/220254/why-is-web-sql-database-deprecated" target="_blank">Websql is deprecated</a>. You should not use the websql adapter unless you have a really good reason.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-websql --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-websql&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;websql&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h1 id="nodejs">NodeJS</h1>
<h2 id="leveldown">leveldown</h2>
<p>This adapter uses a <a href="https://github.com/Level/leveldown" target="_blank">LevelDB C++ binding</a> to store that data on the filesystem. It has the best performance compared to other filesystem adapters. This adapter can <strong>not</strong> be used when multiple nodejs-processes access the same filesystem folders for storage.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install leveldown --save</span>
<span class="hljs-comment">// npm install pouchdb-adapter-leveldb --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-leveldb&apos;</span>)); <span class="hljs-comment">// leveldown adapters need the leveldb plugin to work</span>
<span class="hljs-keyword">const</span> leveldown = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;leveldown&apos;</span>);

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: leveldown <span class="hljs-comment">// the full leveldown-module</span>
});

<span class="hljs-comment">// or use a specific folder to store the data</span>
<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;/root/user/project/mydatabase&apos;</span>,
    adapter: leveldown <span class="hljs-comment">// the full leveldown-module</span>
});
</code></pre>
<h2 id="node-websql">Node-Websql</h2>
<p>This adapter uses the <a href="https://github.com/nolanlawson/node-websql" target="_blank">node-websql</a>-shim to store data on the filesystem. It&apos;s advantages are that it does not need a leveldb build and it can be used when multiple nodejs-processes use the same database-files.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-node-websql --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-node-websql&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;websql&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});

<span class="hljs-comment">// or use a specific folder to store the data</span>
<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;/root/user/project/mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;websql&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h1 id="react-native">React-Native</h1>
<h2 id="asyncstorage">asyncstorage</h2>
<p>Uses react-native&apos;s <a href="https://facebook.github.io/react-native/docs/asyncstorage" target="_blank">asyncstorage</a>.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-asyncstorage --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-asyncstorage&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;node-asyncstorage&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h2 id="react-native-sqlite">react-native-sqlite</h2>
<p>Uses ReactNative SQLite as storage. Claims to be much faster than the asyncstorage adapter.
To use it, you have to do some steps from <a href="https://dev.to/craftzdog/hacking-pouchdb-to-use-on-react-native-1gjh" target="_blank">this tutorial</a>.</p>
<p>First install <code>pouchdb-adapter-react-native-sqlite</code> and <code>react-native-sqlite-2</code>.</p>
<pre><code class="lang-bash">npm install pouchdb-adapter-react-native-sqlite react-native-sqlite-2
</code></pre>
<p>Then you have to <a href="https://facebook.github.io/react-native/docs/linking-libraries-ios" target="_blank">link</a> the library.</p>
<pre><code class="lang-bash">react-native link react-native-sqlite-2
</code></pre>
<p>You also have to add some polyfills which are need but not included in react-native.</p>
<pre><code class="lang-bash">npm install base-64 events
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { decode, encode } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;base-64&apos;</span>

<span class="hljs-keyword">if</span> (!global.btoa) {
    global.btoa = encode;
}

<span class="hljs-keyword">if</span> (!global.atob) {
    global.atob = decode;
}

<span class="hljs-comment">// Avoid using node dependent modules</span>
process.browser = <span class="hljs-literal">true</span>;
</code></pre>
<p>Then you can use it inside of your code.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { addRxPlugin, createRxDatabase } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;rxdb&apos;</span>;
<span class="hljs-keyword">import</span> SQLite <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;react-native-sqlite-2&apos;</span>
<span class="hljs-keyword">import</span> SQLiteAdapterFactory <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;pouchdb-adapter-react-native-sqlite&apos;</span>

<span class="hljs-keyword">const</span> SQLiteAdapter = SQLiteAdapterFactory(SQLite)

addRxPlugin(SQLiteAdapter);
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-http&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;react-native-sqlite&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<h2 id="asyncstorage-down">asyncstorage-down</h2>
<p>A leveldown adapter that stores on asyncstorage.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-asyncstorage-down --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-leveldb&apos;</span>)); <span class="hljs-comment">// leveldown adapters need the leveldb plugin to work</span>

<span class="hljs-keyword">const</span> asyncstorageDown = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;asyncstorage-down&apos;</span>);

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: asyncstorageDown <span class="hljs-comment">// the full leveldown-module</span>
});
</code></pre>
<h1 id="cordova--phonegap">Cordova / Phonegap</h1>
<h2 id="cordova-sqlite">cordova-sqlite</h2>
<p>Uses cordova&apos;s global <code>cordova.sqlitePlugin</code>.</p>
<pre><code class="lang-js"><span class="hljs-comment">// npm install pouchdb-adapter-cordova-sqlite --save</span>
addRxPlugin(<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;pouchdb-adapter-cordova-sqlite&apos;</span>));

<span class="hljs-keyword">const</span> database = <span class="hljs-keyword">await</span> createRxDatabase({
    name: <span class="hljs-string">&apos;mydatabase&apos;</span>,
    adapter: <span class="hljs-string">&apos;node-cordova-sqlite&apos;</span> <span class="hljs-comment">// the name of your adapter</span>
});
</code></pre>
<hr>
<p>If you are new to RxDB, you should continue <a href="tutorials/typescript.html">here</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="plugins.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Plugins">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Adapters","level":"1.20","depth":1,"next":{"title":"Tutorials","level":"1.21","depth":1,"ref":"","articles":[{"title":"Use RxDB with Typescript","level":"1.21.1","depth":2,"path":"tutorials/typescript.md","ref":"./tutorials/typescript.md","articles":[]},{"title":"Using the Server Plugin","level":"1.21.2","depth":2,"path":"tutorials/server.md","ref":"./tutorials/server.md","articles":[]}]},"previous":{"title":"Plugins","level":"1.19","depth":1,"path":"plugins.md","ref":"./plugins.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","github","custom-favicon","-sharing","expandable-chapters","scripts"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/pubkey/rxdb"},"scripts":{"files":["./gitter.js"]},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":"./files/logo/icon.ico","custom-favicon":{},"edit-link":{"label":"Edit This Page","base":"https://github.com/pubkey/rxdb/tree/master/docs-src"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"RxDB - Documentation","links":{"sidebar":{"Follow @twitter ":"https://twitter.com/rxdbjs","Chat @gitter ":"https://gitter.im/pubkey/rxdb","Star @github ":"https://github.com/pubkey/rxdb","Donate @patreon ":"https://www.patreon.com/rxdb/"}},"gitbook":"3.2.3"},"file":{"path":"adapters.md","mtime":"2020-04-17T23:50:35.431Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-06-26T07:42:11.102Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-scripts/c6361af027a93a41d58227852f7ae965-gitter.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

